#ifndef RESIZABLE_ARRAY_H 
#define RESIZABLE_ARRAY_H 

#include "array.h"
#include "dynamic_array.h"

template<class T>
class ResizableArray : public Array<T>{
private:
    DynamicArray<T>* buf;
    int sz;

    void init(const int sz);

protected:
    virtual const T* start() const { return this->buf != 0 ? &(*this->buf)[0] : 0; }
    virtual T* start() { return this->buf != 0 ? &(*this->buf)[0] : 0; }

public:
    ResizableArray(const int sz = 0, const T src[] = 0);
    ResizableArray(const Array<T>& src);

    virtual ~ResizableArray();

    virtual void valid() const;
    virtual int size() const { return this->sz; }

    void operator=(const Array<T>& src);

    int capacity() const { return this->buf != 0 ? this->buf->size() : 0; }

    void resize(const int reqSize);
    void reserve(int reqCapacity);

    void append(const T data[], const int dataSize);
    void append(const Array<T>& data);

    void insert(const int start, const Array<T>& data);
    void insert(const int start, const T data[], const int dataSize);

    void remove(const int start, const int sizeToRemove);
};

#include "resizable_array_impl.h"

#endif /*#define RESIZABLE_ARRAY_H */
